package com.casic.ops.controller;

import com.casic.ops.annotation.EventLog;
import com.casic.ops.annotation.RestWrapper;
import com.casic.ops.consts.event.EventType;
import com.casic.ops.service.api.IAppStoreService;
import com.casic.ops.utils.OpsAssert;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * import org.springframework.web.bind.annotation.RestController;
 * <p>
 * /**
 *
 * @ClassName ops
 * @Description app 商店的安装程序
 * @Author mianbin
 * @Date 2022/6/16 16:25
 * @Version 1.0
 **/
@RestController
@RestWrapper
@RequestMapping("/ops/api/app-store")
public class AppStoreController {

    @Resource
    private IAppStoreService appStoreService;

    /**
     * 添加应用
     */
    @GetMapping("/install")
    @EventLog(EventType.ADD_APP)
    public Integer installApp(
            @RequestParam("appName") String appName
            , @RequestParam(value = "appVerison", required = false, defaultValue = "version.1.0.0") String appVerison
            , @RequestParam("machineId") Long machineId) {
        OpsAssert.allNotBlank(appName, appVerison);
        return appStoreService.appInstall(appName, appVerison, machineId);
    }
}
